$OpenBSD: patch-aub,v 1.1 2001/04/07 21:45:09 naddy Exp $
--- aub.orig	Sat Apr  7 23:07:34 2001
+++ aub	Sat Apr  7 23:11:14 2001
@@ -1,4 +1,4 @@
-#/usr/local/bin/perl
+#!/usr/bin/perl
 #
 #
 #
@@ -35,9 +35,11 @@
 #				    in the standard place.
 
 $ECHO = "/bin/echo"; &find_pg("echo", 0) unless (-x $ECHO);
-$SUM = "/bin/sum";   &find_pg("sum", 0)  unless (-x $SUM);
+$SUM = "/usr/bin/sum";   &find_pg("sum", 0)  unless (-x $SUM);
 $CAT = "/bin/cat";   &find_pg("cat", 0)  unless (-x $CAT);
 $MV = "/bin/mv";     &find_pg("mv", 0)   unless (-x $MV);
+$HOSTNAME = "/bin/hostname"; $HOSTNAME = &find_pg("hostname", 0) unless
+  (-x $HOSTNAME);
 
 # CONSTANTS: 	most likely you want to leave these alone.  
 #
@@ -111,7 +113,7 @@ $aub_config 	    = join("/", $ENV{"HOME"
 $timeout_interval   = 60;
 $version	    = "2.0.5";
 $last_version	    = "1.1";
-$temp_decode_file   = "/usr/tmp/aub.decode$$";
+$temp_decode_file   = "/var/tmp/aub.decode$$";
 $nntpserver_file    = "/usr/local/lib/rn/nntpserver";
 $obsolete_init	    = join("/", $ENV{"HOME"}, ".aubinit");
 
@@ -149,6 +151,12 @@ $obsolete_init	    = join("/", $ENV{"HOM
 # v2.1 will be bug fixes for v2.0.)
 #
 
+# Modified the 7th of december 1994 by Laurent VALLEE
+# in purpose of compatibility with Perl 5 :
+#
+# load the socket library to connect the server in NNTP mode
+BEGIN { require "Socket.pm"; import Socket; }
+
 (&Getopts("cd:nCMm")) || (exit(1));
 
 &long_manual if ($opt_M);			# None of these subroutines
@@ -198,15 +206,21 @@ if ($spooldir) {
          "environment variable\nor specify an NNTP server or disk based " .
          "news access in your configuration file.") unless ($server);
 
-  if ($opt_d > 1) {
-    print "Searching library directories:";
-    foreach $libr (@INC) {
-      print " $libr";
-    }
-    print " for sys/socket.ph...\n";
-  } 
+# Modified the 7th of december 1994 by Laurent VALLEE
+# in purpose of compatibility with Perl 5 :
+#
+# no need to load the socket library because it has already been done
+# at the beginning of the script. So comment the lines...
+
+#  if ($opt_d > 1) {
+#    print "Searching library directories:";
+#    foreach $libr (@INC) {
+#      print " $libr";
+#    }
+#    print " for sys/socket.ph...\n";
+#  } 
 
-  &need_to_run_h2ph unless (eval("require <sys/socket.ph>"));
+#  &need_to_run_h2ph unless (eval("require <sys/socket.ph>"));
 
   print "Using NNTP-based news access; server is $server\n"
     if ($opt_d);
@@ -929,9 +943,16 @@ sub get_nntp_header {
   local($sock) = pop(@_);
   local($line) = &getline($sock);
 
+  if ($line =~ m/INN/) {                        # This code by mwe@dfw.net,
+    &putline($sock, "mode reader");             #  looks pretty good to me.
+    &getline($sock);                            #   -mfs, 2/95.
+  }
+
   return if (($line =~ m/^200\s/) || ($line =~ m/^201\s/));
+  &abort("Remote nntp service is too busy to talk to us now.")
+    if ($line =~ m/^400\s/);
   &abort("Remote nntp service doesn't look like nntp service to me.");
-} 
+}
 
 
 sub setup_socket_io {
@@ -1022,7 +1043,7 @@ sub connect_tcp {
   local($protocol) = "tcp";
   local($thishost, $problem, $junk);
 
-  $thishost = `hostname`; chop $thishost;
+  $thishost = `$HOSTNAME`; chop $thishost;
 
 # Figure out our address...
   ($name, $junk, $junk, $junk, $ouraddr) = gethostbyname($thishost);
@@ -1875,6 +1896,12 @@ EOF
 }
 
 
+# Modified the 7th of december 1994 by Laurent VALLEE
+# in purpose of compatibility with Perl 5 :
+#
+# in strings, "@" must be preceded by a "\". So the mail adresses
+# must be modified.
+
 sub long_manual {
 #
 #
@@ -2463,8 +2490,8 @@ by the program.
 
 
 						Mark Stantz
-						stantz@sierra.stanford.edu
-						stantz@sgi.com
+						stantz\@sierra.stanford.edu
+						stantz\@sgi.com
 						8/92
 
 EOF
@@ -2482,7 +2509,12 @@ sub tribute {
 # This has some (not much) value as a debugging aid.
 #
 
-&abort("", &process_line(join('&',"82G5S=\"!A;F]T:","5R('!E<FP@:","%C:V5R"),4))
+# Modified the 7th of december 1994 by Laurent VALLEE
+# in purpose of compatibility with Perl 5 :
+#
+# in strings, "@" must be preceded by a "\". So modify the expression.
+
+&abort("", &process_line(join('&',"82G5S=\"!A;F]T:","5R('!E<FP\@:","%C:V5R"),4))
   if (open(DECODE, ">&STDOUT"));
 }
 
@@ -2510,4 +2542,5 @@ sub debug_parser {
   print "spool $spooldir\nnntp $server\n";
   print "debug $opt_d xhdr $have_gotten_subj_line_before\n";
 }
+
 
